<div id="seitcm_wrapper_ms">
	<div id="seitcm_header">
    	<div id="seitcm_head_logo">
            <h1><?php _e('Sunshine Education','SEITCM') ?></h1>
            <h2><?php  echo __('Register statitics','SEITCM') ?></h2>
        </div>
        
        <div id="seitcm_head_menu">
        </div>
        <div class="seitcm_clearfload"></div>
    </div>
    <?php
    $seitcm_form = isset($_GET['seitcm_from']) ? $_GET['seitcm_from'] : seitcm_get_current_date(0,-6,0);
    $seitcm_to = isset($_GET['seitcm_to']) ? $_GET['seitcm_to'] : seitcm_get_current_date();
    $seitcm_class1 = isset($_GET['seitcm_class1']) ? $_GET['seitcm_class1'] : 0;
    $seitcm_class2 = isset($_GET['seitcm_class2']) ? $_GET['seitcm_class2'] : 0;
    ?>
    <form class="seitcm_submitby_datepicker" method="get" action="admin.php?page=seitcm_registration_statistics&action=filter">
    <div class="seitcm_bigwidget_block">
    	<div class="seitcm_bigwidget_block_inner">
    		<h3>
    			<input type="hidden" name="page" value="seitcm_registration_statistics">
    			<label for="seitcm_from" style="clear: none; float: none; width: auto;"><?php echo __('Register statitics','SEITCM').' '.__('from','SEITCM')?></label>
    			<input id="seitcm_from" style="clear: none; float: none; margin-top: -3px; width: 110px;" name="seitcm_from" value="<?php echo $seitcm_form?>" class="text ui-widget-content ui-corner-all seitcm_datemypostpicker" >
    			
    			<label for="seitcm_to" style="clear: none; float: none; width: auto;"><?php _e('to','SEITCM')?></label>
    			<input id="seitcm_to" style="clear: none; float: none; margin-top: -3px; width: 110px;" name="seitcm_to" value="<?php echo $seitcm_to?>" class="text ui-widget-content ui-corner-all seitcm_datemypostpicker" >
    			</h3>
			<?php
			require_once 'seitcm_chart_register.php';
			?>
		</div>
	</div>
	
    <div class="seitcm_bigwidget_block">
    	<div class="seitcm_bigwidget_block_inner">
    		<h3>
    		<?php 
    		$classlisst = seitcm_get_list_class_present();
    		_e('Class','SEITCM');
    		?>
    		<select name="seitcm_class1" onchange='this.form.submit()'>
    			<option value="0" <?php echo $seitcm_class1 == "0" ? 'selected="selected"' : ''?>><?php _e('Chose','SEITCM')?></option>
    			<?php 
    				foreach ($classlisst as $class){
				?>
						<option value="<?php echo $class->id?>" <?php echo $seitcm_class1 == $class->id ? 'selected="selected"' : ''?>><?php echo $class->codename.'.'.$class->classcode?></option>
				<?php 
					}
    			?>
    		</select>
    		<?php _e(' and ','SEITCM')?>
    		<select name="seitcm_class2" onchange='this.form.submit()'>
    			<option value="0" <?php echo $seitcm_class2 == "0" ? 'selected="selected"' : ''?>><?php _e('Chose','SEITCM')?></option>
    			<?php 
    				foreach ($classlisst as $class){
				?>
						<option value="<?php echo $class->id?>" <?php echo $seitcm_class2 == $class->id ? 'selected="selected"' : ''?>><?php echo $class->codename.'.'.$class->classcode?></option>
				<?php 
					}
    			?>
    		</select>
    		</h3>
    		<div class="clear-float"></div>
    		<?php
    			if($seitcm_class1!=0){
	    			$seitcm_result = seitcm_get_class_student_list($seitcm_class1);
    			$ar = array(0,0,0,0);
    			foreach ($seitcm_result as $seitcm_row)
    			{
    				$learnningstatus = get_user_meta($seitcm_row->ID, 'learningstatus', true);
    				$ar[$learnningstatus-1] +=1;
    			}
	    	?>
    		<script type="text/javascript">
			      google.load("visualization", "1", {packages:["corechart"]});
			      google.setOnLoadCallback(drawChart);
			      function drawChart() {
			        var data = google.visualization.arrayToDataTable([
			          ['Student status', 'Count'],
			          <?php 
			          global $seitcm_student_status;
			          foreach ($seitcm_student_status as $seitcm_status){
							echo '[\''.$seitcm_status['Value'].'\','.$ar[$seitcm_status['key']-1].'],';
			          }
			          ?>
			        ]);
			
			        var options = {
			          title: 'Student status statitic <?php echo seitcm_get_class_name($seitcm_class1)?>'
			        };
			
			        var chart = new google.visualization.PieChart(document.getElementById('chart_div_1'));
			        chart.draw(data, options);
			      }
	    	</script>
			<div id="chart_div_1" style="height: 350px; width: 50%; float: left"></div>
			<?php }?>
			<?php
    			if($seitcm_class2!=0){
	    			$seitcm_result = seitcm_get_class_student_list($seitcm_class2);
    			$ar = array(0,0,0,0);
    			foreach ($seitcm_result as $seitcm_row)
    			{
    				$learnningstatus = get_user_meta($seitcm_row->ID, 'learningstatus', true);
    				$ar[$learnningstatus-1] +=1;
    			}
	    	?>
    		<script type="text/javascript">
			      google.load("visualization", "1", {packages:["corechart"]});
			      google.setOnLoadCallback(drawChart);
			      function drawChart() {
			        var data = google.visualization.arrayToDataTable([
			          ['Student status', 'Count'],
			          <?php 
			          global $seitcm_student_status;
			          foreach ($seitcm_student_status as $seitcm_status){
							echo '[\''.$seitcm_status['Value'].'\','.$ar[$seitcm_status['key']-1].'],';
			          }
			          ?>
			        ]);
			
			        var options = {
			          title: 'Student status statitic <?php echo seitcm_get_class_name($seitcm_class2)?>'
			        };
			
			        var chart = new google.visualization.PieChart(document.getElementById('chart_div_2'));
			        chart.draw(data, options);
			      }
	    	</script>
			<div id="chart_div_2" style="height: 350px; width: 50%; float: left"></div>
			<?php }?>
			<div>
			<table class="seitcm_grid parent_table">
				<tr>
				<?php if($seitcm_class1!=0) {?>
					<th style="background: #fff"><?php echo __('only in ','SEITCM') . seitcm_get_class_name($seitcm_class1)?></th>
				<?php } if($seitcm_class1!=0 && $seitcm_class2!=0) {?>
					<th style="background: #fff"><?php echo __('both ','SEITCM') . seitcm_get_class_name($seitcm_class1) . __(' and ','SEITCM') . seitcm_get_class_name($seitcm_class2)?></th>
				<?php } if($seitcm_class2!=0) {?>
					<th style="background: #fff"><?php echo __('only in ','SEITCM') . seitcm_get_class_name($seitcm_class2)?></th>
				<?php }?>
				</tr>
				<tr>
					<?php if($seitcm_class1!=0){?>
					<td style="padding: 0px; vertical-align: top;">
						<table class="seitcm_grid">
							<tr>
								<th><?php _e('NO','SEITCM')?></th>
								<th><?php _e('Student','SEITCM')?></th>
								<th><?php _e('DOB','SEITCM')?></th>
							</tr>
							<?php 
								$this_list = seitcm_class_student_filter($seitcm_class1, $seitcm_class2);
								$i=0;
								foreach ($this_list as $row){
							?>
							<tr>
								<td><?php echo ++$i?></td>
								<td><?php echo get_user_meta($row->studentid,'first_name',true).' '.get_user_meta($row->studentid,'last_name',true)?></td>
								<td><?php echo get_user_meta($row->studentid,'dob',true)?></td>
							</tr>
							<?php }?>
						</table>
					</td>
					<?php }?>
					<?php if($seitcm_class1!=0 && $seitcm_class2!=0){?>
					<td style="padding: 0px; background:#f2f2f2; border-left:1px #ccc solid; border-right:1px #ccc solid; vertical-align: top;">
						<table class="seitcm_grid">
							<tr>
								<th><?php _e('NO','SEITCM')?></th>
								<th><?php _e('Student','SEITCM')?></th>
								<th><?php _e('DOB','SEITCM')?></th>
							</tr>
							<?php 
								$this_list = seitcm_class_student_common($seitcm_class1, $seitcm_class2);
								$i=0;
								foreach ($this_list as $row){
							?>
							<tr>
								<td><?php echo ++$i?></td>
								<td><?php echo get_user_meta($row->studentid,'first_name',true).' '.get_user_meta($row->studentid,'last_name',true)?></td>
								<td><?php echo get_user_meta($row->studentid,'dob',true)?></td>
							</tr>
							<?php }?>
						</table>
					</td>
					<?php }?>
					<?php if($seitcm_class2!=0){?>
					<td style="padding: 0px; vertical-align: top;">
						<table class="seitcm_grid">
							<tr>
								<th><?php _e('NO','SEITCM')?></th>
								<th><?php _e('Student','SEITCM')?></th>
								<th><?php _e('DOB','SEITCM')?></th>
							</tr>
							<?php 
								$this_list = seitcm_class_student_filter($seitcm_class2, $seitcm_class1);
								$i=0;
								foreach ($this_list as $row){
							?>
							<tr>
								<td><?php echo ++$i?></td>
								<td><?php echo get_user_meta($row->studentid,'first_name',true).' '.get_user_meta($row->studentid,'last_name',true)?></td>
								<td><?php echo get_user_meta($row->studentid,'dob',true)?></td>
							</tr>
							<?php }?>
						</table>
					</td>
				<?php }?>
				</tr>
			</table>
			</div>
    	</div>
    </div>
    </form>
</div>